﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class User_Default : AbstractUI
{
    public List<product> allProduct = new List<product>();
    ProductDAO proDao = new ProductDAO();
    int start = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        allProduct = proDao.readAll();
    }

    public String productDetail()
    {

        //Response.Redirect("productdetail.aspx");
        return "productdetail.aspx";
    }
    public void addCart()
    {
        {
            try
            {
                add();
            }
            catch(Exception ex){
                //return "Default.aspx";
            }
        }
        //return null;
    }
    void add() {
        String idS = Request["id"].ToString();
        if (idS != "")
        {
            int id = int.Parse(idS);
            product pro = proDao.readByID(id);
            ShoppingCart.addCart(pro);
            Response.Redirect("Default.aspx");

        }
    }
    //protected void addCartClick(object sender, Comma e)
    //{
    //    int id = int.Parse(e.CommandArgument.ToString());
    //    ////product p = (product)e.CommandArgument;
    //    product p = proDao.readByID(id);
    //    ShoppingCart.addCart(p);
    //}
    protected void addcartClick(object sender, EventArgs e)
    {
        LinkButton l = (LinkButton)sender;
        String ist = l.CommandArgument;
        int id = int.Parse(ist);
        product p = proDao.readByID(id);
        ShoppingCart.addCart(p);
    }
}